 /*///////////////////////////////////////////////////////////////////////////////
-- Author:      liuhx
-- Created:     Fri Nov 16 13:21:28 CST 2018
-- Description:	    
-- If you have any question,please email to liuhx@gentlesoft.com.cn 
////////////////////////////////////////////////////////////////////////////////*/
package com.ctsi.product.service;

 import com.ctsi.commons.util.UtilValidate;
 import com.ctsi.commons.util.id.UUIDGenerator;
 import com.ctsi.commons.util.response.Page;
 import com.ctsi.framework.mybatis.support.MybatisGenericDao;
 import com.ctsi.product.entity.LiulanController;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

 import java.util.List;
 import java.util.Map;


/**
 * LiulanController Service 类
 * @author   liuhx
 * @description  LiulanController
 * @created	 Fri Nov 16 13:21:28 CST 2018
 */

@Service
public class LiulanControllerService {
	private static final Logger logger=LoggerFactory.getLogger(LiulanControllerService.class);
	@Autowired
	private MybatisGenericDao dao;

/**
 * 查询浏览记录表数据量
 *
 */
public  Object selectNumByProductId(String productId){
	logger.debug("selectNumByProductId {}",productId);
	return 	 dao.queryForObject(LiulanController.class.getName() + ".selectLiuLanNumByProductId", productId);
}

	/**
	 * 每次点击详情按钮都会生成一条浏览记录
	 */
	public int insertLiulanController(LiulanController liulanController){
		if(UtilValidate.isEmpty(liulanController.getId()))
			liulanController.setId(UUIDGenerator.getId());
		logger.debug("insert {}",liulanController);
		return dao.insert(liulanController);
	}	
	/**
	 * 动态更新
	 */	
	public int updateLiulanControllerByPKSelective(LiulanController liulanController){
		logger.debug("updateByPrimaryKeySelective {}",liulanController);
		return dao.update(LiulanController.class.getName()+".updateByPrimaryKeySelective", liulanController);
	}
	/**
	 * 更新
	 */
	public int updateLiulanController(LiulanController liulanController){
		logger.debug("update {}",liulanController);
		return dao.update(liulanController);
	}
	
	
	public LiulanController editLiulanControllerById(String id){
		if(UtilValidate.isEmpty(id))
			return null;
		logger.debug("editById {}",id);
		return (LiulanController)dao.queryForObject(LiulanController.class.getName()+".edit", id);
	}
	/**
	 * 根据ID查找 LiulanController对象
	 */
	public LiulanController findLiulanControllerById(String productId){
		if(UtilValidate.isEmpty(productId))
			return null;
		logger.debug("findById {}",productId);
		return dao.get(LiulanController.class, productId);
	}
	/**
	 * 删除LiulanController对象
	 */
	public int removeLiulanController(String id){	
		if(UtilValidate.isNotEmpty(id))
			return dao.delete(LiulanController.class.getName()+".delete", id);
			//return dao.remove(id);
		return 0;
	}
	
	/**
	 * 详细页查询
	 */
	public LiulanController findByDetail(String id){
		return (LiulanController)dao.queryForObject(LiulanController.class.getName()+".findByDetail",id);
	}
	/** 
	 * 多条件查询结果 
	 */
	public Page<LiulanController> findByMulitCondition(Map<String,Object> param , int start , int pageSize){
		logger.debug("findByMulitCondition {}",param);
		if(pageSize<0||pageSize>2000)
			pageSize=Page.DEFAULT_PAGE_SIZE;
		if(start!=-1)
			return dao.queryPage(LiulanController.class.getName()+".selectMulitCondition", param, start, pageSize);
		else{
			throw new RuntimeException("参数不正确 !!");
		}
	}
	/** 
	 * 多条件查询结果不分页
	 */
	public List<LiulanController> find(Map<String,Object> map){
		logger.debug("find {}",map);
		return (List<LiulanController>)dao.queryForList(LiulanController.class.getName()+".selectByMap",map);
	}
	
}
